﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include "IFamilySketchCurve.h"

namespace gcmp
{
    class IGraphicsPlaneCurve;
    class GCurve2d;
}

namespace gfam
{
    /// \brief 2D草图广义曲线
    class GM_FAMILY_SERVICE_EXPORT IFamily2DSketchGeneralCurve : public IFamilySketchCurve
    {
        DEFINE_CAST_DERIVED(gfam::IFamily2DSketchGeneralCurve, gfam::IFamilySketchCurve)
    public:
        /// \brief  创建草图直线
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  start 起点
        /// \param  end   末点
        /// \return 草图直线
        static IFamily2DSketchGeneralCurve* CreateAsLine(gcmp::IDocument *pDocument
            , const gcmp::ElementId &sketchId, const gcmp::ElementId &sketchPlaneId
            , const gcmp::Vector3d &start, const gcmp::Vector3d &end);

        /// \brief  创建草图直线（轴线）
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  start 起点
        /// \param  end   末点
        /// \return 草图直线
        static IFamily2DSketchGeneralCurve* CreateAsAxisLine(gcmp::IDocument *pDocument
            , const gcmp::ElementId &sketchId, const gcmp::ElementId &sketchPlaneId
            , const gcmp::Vector3d &start, const gcmp::Vector3d &end);

        /// \brief  创建草图直线（定位线）
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  start 起点
        /// \param  end   末点
        /// \return 草图直线
        static IFamily2DSketchGeneralCurve* CreateAsLocationLine(gcmp::IDocument *pDocument
            , const gcmp::ElementId &sketchId, const gcmp::ElementId &sketchPlaneId
            , const gcmp::Vector3d &start, const gcmp::Vector3d &end);

        /// \brief 创建草图圆弧
        ///
        /// \param pDocument 文档类
        /// \param sketchId 草图
        /// \param sketchPlaneId 草图平面
        /// \param startPoint 起点坐标
        /// \param endPoint 终点坐标
        /// \param refPoint 参考点
        /// \return 返回创建的草图圆弧
        static IFamily2DSketchGeneralCurve* CreateAsArc(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , const gcmp::Vector3d& startPoint
            , const gcmp::Vector3d& endPoint
            , const gcmp::Vector3d& refPoint);

        /// \brief 创建草图圆弧
        ///
        /// \param pDocument 文档类
        /// \param sketchId 草图
        /// \param sketchPlaneId 草图平面
        /// \param centerPoint 圆心
        /// \param xDir x轴方向
        /// \param yDir y轴方向
        /// \param radius y轴方向
        /// \param startAngle 起始弧度
        /// \param endAngle 终止弧度
        /// \param bAntiClockwise 弧顺逆方向，true：逆时， false：顺时
        /// \return 返回创建的草图圆弧
        static IFamily2DSketchGeneralCurve* CreateAsArc(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , const gcmp::Vector3d& centerPoint
            , const gcmp::Vector3d& xDir
            , const gcmp::Vector3d& yDir
            , double radius
            , double startAngle
            , double endAngle
            , bool bAntiClockwise);

        /// \brief 创建草图圆弧
        ///
        /// \param pDocument 文档类
        /// \param sketchId 草图
        /// \param sketchPlaneId 草图平面
        /// \param centerPoint 圆心
        /// \param startPoint 起点坐标
        /// \param endPoint 终点坐标
        /// \param bAntiClockwise 弧顺逆方向，true：逆时， false：顺时
        /// \return 返回创建的草图圆弧
        static IFamily2DSketchGeneralCurve* CreateAsArc(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , const gcmp::Vector3d& centerPoint
            , const gcmp::Vector3d& startPoint
            , const gcmp::Vector3d& endPoint
            , bool bAntiClockwise);

        /// \brief  创建草图椭圆线
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  center 中心点
        /// \param  normal 法向
        /// \param  majorAxis 主轴方向
        /// \param  majorRadius 主轴半径
        /// \param  minorRadius 副轴半径
        /// \param  startAngle 起始角度
        /// \param  endAngle 终止角度
        /// \param bAntiClockwise 弧顺逆方向，true：逆时， false：顺时
        /// \return 草图椭圆线
        static IFamily2DSketchGeneralCurve* CreateAsEllipse(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , const gcmp::Vector3d& center
            , const gcmp::Vector3d& normal
            , const gcmp::Vector3d& majorAxis
            , double majorRadius
            , double minorRadius
            , double startAngle
            , double endAngle
            , bool bAntiClockwise);

        /// \brief  创建草图椭圆线
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  center 中心点
        /// \param  normal 法向
        /// \param  majorAxis 主轴方向
        /// \param  majorRadius 主轴半径
        /// \param  minorRadius 副轴半径
        /// \param  range 角度区间
        /// \param bAntiClockwise 弧顺逆方向，true：逆时， false：顺时
        /// \return 草图椭圆线
        static IFamily2DSketchGeneralCurve* CreateAsEllipse(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , const gcmp::Vector3d& center
            , const gcmp::Vector3d& normal
            , const gcmp::Vector3d& majorAxis
            , double majorRadius
            , double minorRadius
            , const gcmp::Intervald &range
            , bool bAntiClockwise);

        /// \brief  创建Nurbs曲线
        ///  不指定节点矢量，由内部自动计算；并且不指定权值，所有控制点的权值设为1
        ///  软件内部创建样条曲线，通常使用这个方法
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  degree    度
        /// \param  controlPts 控制点
        /// \return Nurbs曲线
        static IFamily2DSketchGeneralCurve* CreateAsNurbsByControlPoints(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , int degree
            , const std::vector<gcmp::Vector3d>& controlPts);

        /// \brief  创建Nurbs曲线
        ///
        /// \param  pDocument  文档
        /// \param  sketchId 草图id
        /// \param  sketchPlaneId 草图平面id
        /// \param  throughPts 通过点
        /// \return Nurbs曲线
        static IFamily2DSketchGeneralCurve* CreateAsNurbsByThroughPoints(
            gcmp::IDocument* pDocument
            , const gcmp::ElementId& sketchId
            , const gcmp::ElementId& sketchPlaneId
            , const std::vector<gcmp::Vector3d>& throughPts);

        /// \brief 获取ImplementationUid
        /// 
        /// \return ImplementationUid
        static gcmp::UniIdentity GetImplementationUid();

        /// \brief 获取2D曲线
        ///
        /// \return 2D曲线
        virtual gcmp::GCurve2d* GetGCurve2dFW() = 0;

        /// \brief 获取2D曲线
        ///
        /// \return 2D曲线
        virtual const gcmp::GCurve2d* GetGCurve2d() const = 0;

        /// \brief 设置2D曲线
        ///
        /// \param opGCurve2d 2D曲线
        virtual void SetGCurve2d(gcmp::OwnerPtr<gcmp::GCurve2d> opGCurve2d) = 0;

        /// \brief 获取2D曲线关联更新数据Id
        ///
        /// \return 2D曲线关联更新数据Id
        virtual RegenDataId GetGCurve2dRdId() const = 0;

        /// \brief 设置草图平面Id
        ///
        /// \param idSketchPlane 草图平面Id
        virtual void SetSketchPlaneId(const gcmp::ElementId& idSketchPlane) = 0;

        /// \brief 获取草图平面Id
        ///
        /// \return 草图平面Id
        virtual gcmp::ElementId GetSketchPlaneId() const = 0;

        /// \brief 获取平面曲线，约束解算时使用
        ///
        /// \return 平面曲线
        virtual const gcmp::IGraphicsPlaneCurve* GetGPlaneCurve() const = 0;

        /// \brief 获取平面曲线，约束解算时使用
        ///
        /// \return 平面曲线
        virtual gcmp::IGraphicsPlaneCurve* GetGPlaneCurveFW() = 0;

        /// \brief 设置平面曲线
        ///
        /// \param opGPlaneCurve 平面曲线
        virtual void SetGPlaneCurve(gcmp::OwnerPtr<gcmp::IGraphicsPlaneCurve> opGPlaneCurve) = 0;

        /// \brief 创建约束符号
        ///
        /// \param pModelView 视图
        virtual void CreateConstraintSymbol(gcmp::IModelView *pModelView = nullptr) const = 0;

        /// \brief 曲线反向
        virtual void Reverse() = 0;

        /// \brief 获取曲线中心（圆心、椭圆心）是否可见
        ///
        /// \return 曲线中心是否可见
        virtual bool GetCenterVisible() const = 0;

        /// \brief 设置曲线中心（圆心、椭圆心）是否可见
        ///
        /// \param  bVisible 曲线中心是否可见
        virtual void SetCenterVisible(bool bVisible) = 0;

        /// \brief 获取曲线中心可见性的关联更新Id
        ///
        /// \return 关联更新Id
        virtual RegenDataId GetCenterVisibleRdId() const = 0;

        /// \brief  获取Nurbs曲线是否通过点模式
        ///
        /// \param  是返回true，否则返回false
        virtual bool GetIsThroughPointsMode() const = 0;

        /// \brief  设置Nurbs曲线通过点模式
        ///
        /// \param bIsThroughPtsMode 模式
        virtual void SetIsThroughPointsMode(bool bIsThroughPtsMode) = 0;

        /// \brief  获取Nurbs曲线通过点
        ///
        /// \return 通过点
        virtual const std::vector<gcmp::Vector3d>& GetThroughPoints() const = 0;

        /// \brief  获取Nurbs曲线通过点
        ///
        /// \return 通过点
        virtual std::vector<gcmp::Vector3d>& GetThroughPointsFW() = 0;

        /// \brief  设置Nurbs曲线通过点
        ///
        /// \param newThroughtPts 通过点
        virtual void SetThroughPoints(const std::vector<gcmp::Vector3d> &newThroughtPts) = 0;

        /// \brief  获取引用对象
        ///
        /// \return 引用对象
        virtual const gcmp::IGraphicsNodeReference* GetGNodeRefObj() const = 0;

        /// \brief 设置引用对象
        ///
        /// \param opReferenceObject 引用对象
        virtual void SetGNodeRefObj(gcmp::OwnerPtr<gcmp::IGraphicsNodeReference> opReferenceObject) = 0;

        /// \brief  获取引用对象关联更新id
        ///
        /// \return 引用对象关联更新id
        virtual RegenDataId GetGNodeRefObjRdId() const = 0;

        /// \brief  根据引用对象，更新草图线的几何
        virtual void ComputeGCurveFromReference() = 0;
    };
}